package com.example.personnel.repository;

import com.example.personnel.model.Personnel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface PersonnelRepository extends JpaRepository<Personnel, Long> {
    List<Personnel> findByNameContaining(String name);
    List<Personnel> findByPosition(String position);
    
    @Query("SELECT p FROM Personnel p WHERE " +
           "(:name IS NULL OR :name = '' OR p.name LIKE %:name%) AND " +
           "(:position IS NULL OR :position = '' OR p.position LIKE %:position%) AND " +
           "(:gender IS NULL OR :gender = '' OR p.gender = :gender)")
    List<Personnel> findByConditions(
        @Param("name") String name,
        @Param("position") String position,
        @Param("gender") String gender
    );
} 